package com.lindroy.androidplayer.ui.adapter

import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.DiffUtil
import com.lindroy.androidplayer.base.adapter.BasePagingAdapter
import com.lindroy.androidplayer.databinding.CoinHistoryItemBinding
import com.lindroy.androidplayer.viewmodels.CoinHistoryViewModel

/**
 * @author Lin
 * @date 2022/2/14
 * @function 我的积分列表
 */
class CoinHistoryAdapter(owner: LifecycleOwner) :
    BasePagingAdapter<CoinHistoryViewModel, CoinHistoryItemBinding>(owner,
        object : DiffUtil.ItemCallback<CoinHistoryViewModel>() {
            override fun areItemsTheSame(
                oldItem: CoinHistoryViewModel,
                newItem: CoinHistoryViewModel
            ): Boolean = oldItem.id == newItem.id

            override fun areContentsTheSame(
                oldItem: CoinHistoryViewModel,
                newItem: CoinHistoryViewModel
            ): Boolean = oldItem.date == newItem.date && oldItem.coinCount == newItem.coinCount

        }) {
    override fun CoinHistoryItemBinding.onBindViewHolder(
        item: CoinHistoryViewModel?,
        position: Int
    ) {
        vm = item
    }

}